package _18_剑指OfferII;

public class _068_剑指OfferII查找插入位置 {

    public int searchInsert(int[] nums, int target) {
        int begin = 0;
        int result = nums.length;
        int end = result - 1;
        while (begin <= end) {
            int mid = begin + ((end - begin) >> 1);
            if (nums[mid] >= target) {
                result = mid;
                end = mid - 1;
            } else {
                begin = mid + 1;
            }
        }
        return result;
    }

}
